/**
 * Copyright 2004 Cordys R&D B.V. 
 * 
 * This file is part of the Cordys FTP Connector. 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 package com.eibus.applicationconnector.ftp;

/**
 * A thread safe singleton class which holds the settings of the proxy server
 * configured in the soap processor. These settings are per processor and
 * applies to all the FTP configurations which are served by this processor. 
 * 
 * In the lifetime of the processor, this object is created only once and 
 * exists as long as the soap processor is up and running. An instance of
 * this class is created when a first request comes to the FTP processor
 * with proxy enabled.
 */

public class ProxySettings
{
	/* Holds the port number at which the client is trying to connect to the proxy server */
	private int proxyPort;
	
	/* Holds the type of the proxy. Supported types are HTTP, SOCKS4 and SOCKS5 */
	private String proxyType;
	
	/* Holds the hostname of the server where the proxy is running */
	private String proxyHost;
	
	/* Holds the username of the proxy server*/
	private String proxyUsername;
	
	/* Holds the password of the proxy server*/
	private String proxyPassword;

	/* An instance of "this" which encapsulates the above states */
	private static ProxySettings proxySettings = null;
	
	/**
	 * Private constructor - to restrict the creation of this instance at will
	 */
	private ProxySettings()
	{
		
	}
	
	/**
	 * This method returns a (new) instance of this class.
	 * synchronized this to avoid resulting in bad state changes
	 * in multithreaded situation
	 * 
	 * @return proxySettings
	 */
	public static synchronized  ProxySettings getInstance()
	{
		if (proxySettings == null)
		{
			proxySettings = new ProxySettings();
		}
		
		return proxySettings;
	}
	
	/**
	 * Returns the proxy port
	 * @return proxyPort
	 */
	public int getProxyPort()
	{
		return proxyPort;
	}

	/**
	 * Sets the proxy port
	 * @param proxyPort
	 */
	public void setProxyPort(int proxyPort)
	{
		this.proxyPort = proxyPort;
	}

	/**
	 * Returns the type of the proxy
	 * @return proxyType
	 */
	public String getProxyType()
	{
		return proxyType;
	}

	/**
	 * Sets the proxy type
	 * @param proxyType
	 */
	public void setProxyType(String proxyType)
	{
		this.proxyType = proxyType;
	}

	/**
	 * Returns the host on which the proxy server is running
	 * @return proxyHost
	 */
	public String getProxyHost()
	{
		return proxyHost;
	}

	/**
	 * Sets the host on which the proxy is running 
	 * @param proxyHost
	 */
	public void setProxyHost(String proxyHost)
	{
		this.proxyHost = proxyHost;
	}

	/**
	 * Returns the username that is used to connect to the proxy server
	 * @return proxyUsername
	 */
	public String getProxyUsername()
	{
		return proxyUsername;
	}

	/**
	 * Sets the username that is used to connect to the proxy server
	 * @param proxyUsername
	 */
	public void setProxyUsername(String proxyUsername)
	{
		this.proxyUsername = proxyUsername;
	}

	
	/**
	 * Returns the password that is used to connect to the proxy server
	 * @return proxyPassword
	 */
	public String getProxyPassword()
	{
		return proxyPassword;
	}

	/**
	 * Sets the password that is used to connect to the proxy server
	 * @param proxyPassword
	 */
	public void setProxyPassword(String proxyPassword)
	{
		this.proxyPassword = proxyPassword;
	}
}